package com.ruoyi.costumeShop.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.costumeShop.domain.CostumeRefundOrder;
import com.ruoyi.costumeShop.service.ICostumeRefundOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * refundOrderController
 *
 * @author ruoyi
 * @date 2022-05-14
 */
@RestController
@RequestMapping("/costumeShop/refundOrder")
public class CostumeRefundOrderController extends BaseController
{
    @Autowired
    private ICostumeRefundOrderService costumeRefundOrderService;

    /**
     * 查询refundOrder列表
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:refundOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(CostumeRefundOrder costumeRefundOrder)
    {
        startPage();
        List<CostumeRefundOrder> list = costumeRefundOrderService.selectCostumeRefundOrderList(costumeRefundOrder);
        return getDataTable(list);
    }

    /**
     * 导出refundOrder列表
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:refundOrder:export')")
    @Log(title = "refundOrder", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CostumeRefundOrder costumeRefundOrder)
    {
        List<CostumeRefundOrder> list = costumeRefundOrderService.selectCostumeRefundOrderList(costumeRefundOrder);
        ExcelUtil<CostumeRefundOrder> util = new ExcelUtil<CostumeRefundOrder>(CostumeRefundOrder.class);
        util.exportExcel(response, list, "refundOrder数据");
    }

    /**
     * 获取refundOrder详细信息
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:refundOrder:query')")
    @GetMapping(value = "/{refundOrderId}")
    public AjaxResult getInfo(@PathVariable("refundOrderId") Long refundOrderId)
    {
        return AjaxResult.success(costumeRefundOrderService.selectCostumeRefundOrderByRefundOrderId(refundOrderId));
    }

    /**
     * 新增refundOrder
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:refundOrder:add')")
    @Log(title = "refundOrder", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CostumeRefundOrder costumeRefundOrder)
    {
        return toAjax(costumeRefundOrderService.insertCostumeRefundOrder(costumeRefundOrder));
    }

    /**
     * 修改refundOrder
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:refundOrder:edit')")
    @Log(title = "refundOrder", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CostumeRefundOrder costumeRefundOrder)
    {
        return toAjax(costumeRefundOrderService.updateCostumeRefundOrder(costumeRefundOrder));
    }

    /**
     * 删除refundOrder
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:refundOrder:remove')")
    @Log(title = "refundOrder", businessType = BusinessType.DELETE)
    @DeleteMapping("/{refundOrderIds}")
    public AjaxResult remove(@PathVariable Long[] refundOrderIds)
    {
        return toAjax(costumeRefundOrderService.deleteCostumeRefundOrderByRefundOrderIds(refundOrderIds));
    }
}
